package com.bajie.bjlisten.controller;


import com.bajie.bjlisten.api.BjCategoryControllerApi;
import com.bajie.bjlisten.entity.category_user.BjCategoryUserDto;
import com.bajie.bjlisten.entity.BjUserInterest;
import com.bajie.bjlisten.sevice.BjCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

@RestController
@RequestMapping("/ebooks")
public class BjCategoryController implements BjCategoryControllerApi {

    @Autowired
    BjCategoryService bjCategoryService;

    //TODO:每页显示的条数改为系统配置项
    private Integer pageSize = 10;


    /**
     * 单表分页查询用户喜欢的分类，只包含分类主键、用户Id
     *
     * @param userId
     * @return
     */
    @GetMapping("/{userId}")
    public List<BjUserInterest> findListUserInterest(@PathVariable(value = "userId", required = true) String userId) {
        return bjCategoryService.findListUserInterest(userId, 0, 10);
    }

    /**
     * 两表查户喜欢的分询用类，包含分类名称和分类主键和用户ID
     *
     * @param userId
     * @return
     */
    @GetMapping("/get/{userId}")
    public Set<BjCategoryUserDto> findListUser_Interest(@PathVariable(value = "userId", required = true) String userId) {
        return bjCategoryService.findListUser_Interest(userId, 0, 2);
    }


}
